package com.atguigu.gulimall.auth;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

/**
 * springSession 原理
 * EnableRedisHttpSession导入RedisHttpSessionConfiguration配置
 *      1.给容器中添加了一个组件
 *      SessionRepository   --》 RedisIndexedSessionRepository  session的增删改查
 *      2.SessionRepositoryFilter session存储过滤器
 *
 *  装饰者模式
 *  @Override
 * 	protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
 * 			throws ServletException, IOException {
 * 		request.setAttribute(SESSION_REPOSITORY_ATTR, this.sessionRepository);
 *
 * 		SessionRepositoryRequestWrapper wrappedRequest = new SessionRepositoryRequestWrapper(request, response);
 * 		SessionRepositoryResponseWrapper wrappedResponse = new SessionRepositoryResponseWrapper(wrappedRequest,
 * 				response);
 *
 * 		try {
 * 			filterChain.doFilter(wrappedRequest, wrappedResponse);
 * 		}
 * 		finally {
 * 			wrappedRequest.commitSession();
 * 		}
 * 	}
 */

@EnableRedisHttpSession  //整合redis作为session存储
@EnableFeignClients(basePackages = "com.atguigu.gulimall.auth.feign")
@EnableDiscoveryClient
@SpringBootApplication
public class GulimallAuthServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(GulimallAuthServerApplication.class, args);
    }

}
